//
//  TowPicture.m
//  Four_Fit_New
//
//  Created by lanou on 16/7/14.
//  Copyright © 2016年 xmaz. All rights reserved.
//

#import "TowPicture.h"
#import "Community.h"
#import "comment.h"
#import "NoteModel.h"
#import "ShowPicture.h"

@interface TowPicture ()
@property (weak, nonatomic) IBOutlet UIImageView *leftPic;

@property (weak, nonatomic) IBOutlet UIImageView *rightPic;

@end

@implementation TowPicture

+ (instancetype)towPicture
{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}

- (void)setCommunity:(Community *)community {
    
    _community = community;
    
    [self.leftPic sd_setImageWithURL:[NSURL URLWithString:community.pic[0]]];
    [self.rightPic sd_setImageWithURL:[NSURL URLWithString:community.pic[1]]];
}

- (void)setComment:(comment *)comment {
    _comment = comment;
    [self.leftPic sd_setImageWithURL:[NSURL URLWithString:comment.pic[0]]];
    [self.rightPic sd_setImageWithURL:[NSURL URLWithString:comment.pic[1]]];
}
- (void)setNoteModel:(NoteModel *)noteModel {
    
    _noteModel = noteModel;
    [self.leftPic sd_setImageWithURL:[NSURL URLWithString:noteModel.pic[0]]];
    [self.rightPic sd_setImageWithURL:[NSURL URLWithString:noteModel.pic[1]]];
}

- (void)awakeFromNib {
    
    self.autoresizingMask = UIViewAutoresizingNone;
    
    //添加图片之间的分割线
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake((kWidth - 41) * 0.5, 0, 3, 180)];
    view.backgroundColor = [UIColor whiteColor];
    [self addSubview:view];
    self.leftPic.clipsToBounds = YES;
    self.leftPic.contentMode = UIViewContentModeScaleAspectFit;
    self.rightPic.clipsToBounds = YES;
    self.rightPic.contentMode = UIViewContentModeScaleAspectFit;
    
    [self.leftPic addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showLeftPic)]];
    self.leftPic.userInteractionEnabled = YES;
    [self.rightPic addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showRightPic)]];
    self.rightPic.userInteractionEnabled = YES;
    
}
- (void)showLeftPic{
    [ShowPicture showImage:self.leftPic];
}
- (void)showRightPic {
    [ShowPicture showImage:self.rightPic];
    
}

@end
